package com.quick.develop.flowable.controller.task;

import com.quick.develop.flowable.domain.vo.draft.BpmDraftReqVO;
import com.quick.develop.framework.common.page.PageResult;
import com.quick.develop.framework.common.page.R;
import com.quick.develop.flowable.domain.draft.BpmDraftEx;
import com.quick.develop.flowable.domain.draft.BpmDraftPageReqVO;
import com.quick.develop.flowable.service.task.IBpmDraftService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author junyuan.liu
 * @description: 
 * @date 2022/6/16 11:22
 */
@Api(tags = "流程管理后台 - 流程草稿") 
@RestController
@RequestMapping("/process-draft")
@Validated
public class BpmDraftController {
    @Resource
    IBpmDraftService bpmDraftService;

    @GetMapping("/page")
    @ApiOperation("流程草稿分页")
    public R<PageResult<BpmDraftEx>> draftPage(@Valid BpmDraftPageReqVO vo){
        return R.ok(bpmDraftService.selectPage(vo));
    }

    @GetMapping("/my-count")
    @ApiOperation("流程的数量")
    public R<?> getDraftCount(){
        return R.ok(bpmDraftService.getDraftCount());
    }
    
    @PostMapping("/add")
    @ApiOperation("新增流程草稿")
    public R<?> addDraft(@RequestBody BpmDraftReqVO vo){
        bpmDraftService.addDraft(vo);
        return R.ok();
    }

    @ApiOperation("删除流程草稿")
    @DeleteMapping("/delete/{id}")
    public R<?> deleteDraft(@PathVariable(value = "id") Long id){
        return R.ok(bpmDraftService.deleteDraftById(id));
    }

    @ApiOperation("更新流程草稿")
    @PutMapping("/update")
    public R<?> updateDraft(@RequestBody BpmDraftReqVO vo){
        return R.ok(bpmDraftService.updateDraft(vo));
    }
    
    
    
    
}
